function Person(name) {
    this.name = name
}

let p = new Person("iverson")

// console.log(p.__proto__ === Person.prototype)

function instance_of(L, R) {
    let prototype = R.prototype
    let proto = L.__proto__
    while (true) {
        if (!proto) {
            return false
        }
        if (proto === prototype) {
            return true
        }
        proto = proto.__proto__
    }
}

instance_of(p, Person)
console.log(instance_of(p, Person))
console.log(instance_of(p, Object))
console.log(p instanceof Person)
console.log(p instanceof Object)